package com.lglin.common.utils.reponse;

import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


public class PrintOutUtil {

    public static void printJsonOut(HttpServletResponse response, ResultBean responseBean) throws IOException {
        response.setContentType("application/json;charset=UTF-8");
        response.setCharacterEncoding("utf-8");
        response.getWriter().write(JSONObject.toJSONString(responseBean));
        response.getWriter().flush();
        response.getWriter().close();
    }

    public static void printHtmlOut(HttpServletResponse response, String v) throws IOException {
        response.setContentType("text/html;charset=UTF-8");
        response.setCharacterEncoding("utf-8");
        response.getWriter().write(v);
        response.getWriter().flush();
        response.getWriter().close();
    }

}
